package mo.offer_version2;

import mo.common.ListNode;

import java.util.Stack;

public class L06 {

    public int[] reversePrint(ListNode head) {
        Stack<Integer> stack = new Stack<>();
        while (head != null) {
            stack.push(head.val);
            head = head.next;
        }
        int[] ret = new int[stack.size()];
        int idx = 0;
        while (!stack.isEmpty()) {
            ret[idx++] = stack.pop();
        }
        return ret;
    }

}
